package net.jlibrary.curbparking.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.BatchSize;

import net.jlibrary.common.core.annotation.CodeGenComment;
import net.jlibrary.common.core.annotation.Compositor;
import net.jlibrary.common.core.annotation.SearchCondition;
import net.jlibrary.common.core.annotation.SearchField;
import net.jlibrary.common.core.entity.BaseObject;

/**
 * 图片集，包括车辆驶入、驶出、设备定时抓拍
 * 
 * @author fzys
 *
 */
@Entity(name = "tab_picturegallery")
@BatchSize(size = 15)
@Compositor("occurrenceTime desc,createdate desc")
@CodeGenComment(value = "图片集", genSelect = false)
public class PictureGallery extends BaseObject {
	private static final long serialVersionUID = -5608313959290434033L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@SearchField(value = "id", condition = SearchCondition.EQUAL)
	private Long id;
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "type_id")
	@SearchField(value = "type", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "图片集类别", viewList = true, required = true)
	private PictureGalleryType type;
	@CodeGenComment(value = "对应的主键", viewList = true, required = true)
	private Long pk;
	@Column(length = 120)
	@CodeGenComment(value = "关联的类", viewList = true, required = true)
	private String className;
	@Column(length = 200)
	@CodeGenComment(value = "文件路径", viewList = true, required = true)
	private String fileAbsolutePath;
	@Temporal(TemporalType.TIMESTAMP)
	@CodeGenComment(value = "产生时间", viewList = true)
	private Date occurrenceTime;

	@Column(updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	@CodeGenComment(value = "创建时间", viewList = true)
	private Date createdate;
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastdate;

	public Long getId() {
		return id;
	}

	@Override
	public Serializable getPrimaryKey() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public PictureGalleryType getType() {
		return type;
	}

	public void setType(PictureGalleryType type) {
		this.type = type;
	}

	public Long getPk() {
		return pk;
	}

	public void setPk(Long pk) {
		this.pk = pk;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public String getFileAbsolutePath() {
		return fileAbsolutePath;
	}

	public void setFileAbsolutePath(String fileAbsolutePath) {
		this.fileAbsolutePath = fileAbsolutePath;
	}

	public Date getOccurrenceTime() {
		return occurrenceTime;
	}

	public void setOccurrenceTime(Date occurrenceTime) {
		this.occurrenceTime = occurrenceTime;
	}

	public Date getCreatedate() {
		return createdate;
	}

	public void setCreatedate(Date createdate) {
		this.createdate = createdate;
	}

	public Date getLastdate() {
		return lastdate;
	}

	public void setLastdate(Date lastdate) {
		this.lastdate = lastdate;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PictureGallery other = (PictureGallery) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
}
